<?php

/**
 * @copyright 2012
 */

require_once("SqlUtils.php");
require_once("Account.php");


$name = $_GET["name"];
$money = $_GET["money"];

if(!$name)
{
    echo "name is empty";
    exit;
}
////////////////////////////////////////////////////////
$newAccountID = AddAccount($name,$money);

if($newAccountID == -1)
{
    echo "AddAccount error";
    exit;
}
////////////////////////////////////////////////////////
  $doc = new DOMDocument();
  $doc->formatOutput = true;
  
  $r = $doc->createElement("accounts");
  $doc->appendChild($r);
  
  $account = new Account();
  $account->Init($newAccountID);
  $accountXMLNode = $account->GetXMLNode($doc);
  $r->appendChild($accountXMLNode);
  
  echo $doc->saveXML();
?>